home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / prog / oalrs100.arj / 80X86S.TXT < prev    next >
Text File  |  1994-05-04  |  89KB  |  1,641 lines

  1.                       Credits and Ordering Information.
  2.  
  3.        This text file is an excerpt from "The 80x86 Online Assembly Language
  4.   Reference", an Expert Help database that documents the instructions and
  5.   architecture of the 80x86 family of processors.  The complete reference is
  6.   accessed using Expert Help, a hypertext TSR available from SofSolutions,
  7.   Inc.  This file was created to provide the reader with an impression of
  8.   the contents of the reference.  However, it does not suggest the ease at
  9.   which the information can be found in the online reference or the
  10.   convenience of having the information available from a TSR.
  11.  
  12.        This excerpt was written by Todd Niec at Ware Unlimited, Inc.
  13.   Copyright (c) 1992, 1993, 1994.  This excerpt may be freely distributed in
  14.   its original form, but may not be altered or sold for any reason without
  15.   the express permission of the copyright holders.
  16.  
  17.        This file contains a sample of part of the 80x86 OnLine Assembly
  18.   Language Reference distributed by Ware, Inc.  The complete reference has
  19.   the following features:
  20.  
  21.    Documentation of all the 80x86 instructions and prefixes
  22.     (247 entries) through the 80586 processor, including some little known
  23.     unofficial instructions that Intel does not usually document.
  24.    Entries for 6 instructions available only on 80x86 processors.
  25.    Entries for 5 instructions available only on 80486 and latter
  26.     processors.
  27.    Entries for 78 instructions available only on 80386 and latter
  28.     processors.
  29.    Entries for 2 instructions available only on 80386 processors.
  30.    Over 18,000 lines of documentation.
  31.    The instructions can be found in an alphabetical list or in lists
  32.     that groups instructions by their function.
  33.    Each instruction is carefully documented and includes information on
  34.     instruction timing, encoding, assembler syntax, and algorithms.
  35.    Many entries contain programming tips and examples.
  36.    An overview of the design and features of the 80x86 family of
  37.     processors.
  38.    A section on instruction encoding.
  39.    A description of the 80x86 addressing modes.
  40.    An explanation of timing issues that effect the performance of each
  41.     processor.
  42.    Techniques for optimizing assembly code.
  43.  
  44.        Whether you're a full-time assembly language programmer, or just
  45.   interested in speeding up a bottle-neck with a few lines of assembly code
  46.   the 80x86 OnLine Assembly Language Reference is an absolute must.
  47.  
  48.       Each copy of the database is only $29.95 plus $3 Shipping and handling.
  49.   (when available, 2nd Day shipping is $5 and next day shipping is $10).
  50.   Visa and Mastercard are accepted.
  51.  
  52.       To obtain a copy of the complete 80x86 Online Assembly Language
  53.   Reference, contact Ware Unlimited at (717) 898-7911 or print and mail/FAX
  54.   the order form that appears below.
  55.  
  56.  
  57. ──────────────────────────────────────────────────────────────────────────────
  58.  
  59.  
  60.             80X86 ONLINE ASSEMBLY LANGUAGE REFERENCE ORDER FORM
  61.  
  62.  
  63.                             Ware Unlimited, Inc.
  64.                               195 Broad Street
  65.                              Salunga PA, 17538
  66.                                (717) 898-7911
  67.                             FAX: (717) 898-9107
  68.  
  69.  
  70.  
  71.  
  72.   Please send me ___ copies of the 80x86 Online Assembly Language Reference
  73.   at $29.95 each (plus shipping and handling).
  74.  
  75.   Ship: ___ Surface ($3 each)  ___ 2nd Day ($5 each)  ___ Next Day ($10)
  76.         (2nd day and next day only when available.)
  77.  
  78.   Total Amount: $____.__
  79.  
  80.   Ship To: __________________________________
  81.  
  82.            __________________________________
  83.  
  84.            __________________________________
  85.  
  86.            __________________________________
  87.  
  88.   Phone:   (____) ____ - ______
  89.  
  90.  
  91.   Payment Method:  ___ Master Card ___ Visa ___ Personal Check
  92.  
  93.   Card Number:     __|__|__|__ __|__|__|__ __|__|__|__ __|__|__|__
  94.  
  95.   Expiration Date: ___/19___
  96.  
  97.   Signature:       ______________________________
  98.  
  99.  
  100.  
  101.  
  102. ───────────────────────────────────────────────────────────────────────────────
  103. AAA              ASCII Adjust after Addition         Flags: O D I T S Z A P C
  104.                                                             ?       ? ? * ? *
  105.  
  106. SYNTAX:
  107.   AAA
  108.  
  109. LOGIC:
  110.   IF (AL && 0FH) > 09H OR (AF = 1) THEN
  111.      AL  (AL + 6) && 0FH
  112.      AH  (AH + 1) && 0FH
  113.      AF  1
  114.      CF  1
  115.   ELSE
  116.      AL  AL && 0FH
  117.      AF  0
  118.      CF  0
  119.   ENDIF
  120.  
  121.        This instruction is used to convert the result of adding two unpacked
  122.   BCD digits with the ADD instruction to the proper unpacked BCD digit.
  123.  
  124.       This instruction is necessary because when two unpacked BCD digits are
  125.   added (values from 0 to 9) they produce results from 0 to 18 (19 if ADC
  126.   was used).  However, the values above 9 are not valid unpacked BCD values
  127.   because in decimal notation they must be expressed as two digits.  These
  128.   values occur when there should have been a decimal carry from the digits
  129.   added to the next (more significant) digits.  In these cases AAA will
  130.   convert the result to the proper second digit and add one (a carry) to the
  131.   value in AH.
  132.  
  133.       This instruction is usually used in multi-digit additions.  To use the
  134.   instruction in this way, one of the next digits to be added is stored in
  135.   AH when the AAA is performed, this will add the carry of the current digit
  136.   to the next.  For example:
  137.  
  138. ADDTOP:    MOV     AH,[DI]             ; Get next destination digit.
  139.            MOV     BH,[SI]             ; Get next source digit.
  140.            ADD     AL,BL               ; Add current digits.
  141.            AAA                         ; Convert result to BCD.
  142.            MOV     [DI]-1,AL           ; Store result in destination operand.
  143.            MOV     AL,AH               ; Get new destination digit.
  144.            MOV     BL,BH               ; Get new source digit.
  145.            DEC     DI                  ; Point to next destination digit
  146.            DEC     SI                  ; Point to next source digit
  147.            LOOP    ADDTOP              ; Loop back to add next digit.
  148.  
  149.        Since the AAA instruction also sets the carry flag when there should
  150.   be a carry from the current digit to the next, it is possible to ignore
  151.   the value in AH and add digits with the ADC instruction.  For example:
  152.  
  153. ADDTOP:    MOV     AL,[DI]             ; Get current destination digit.
  154.            MOV     BL,[SI]             ; Get current source digit.
  155.            ADC     AL,BL               ; Add current digits.
  156.            AAA                         ; Convert result to BCD.
  157.            MOV     [DI],AL             ; Store result in destination operand.
  158.            DEC     DI                  ; Point to next destination digit
  159.            DEC     SI                  ; Point to next source digit
  160.            LOOP    ADDTOP              ; Loop back to add next digit.
  161.  
  162.        Since this operation ignores the high nibble of AL and clears the
  163.   high nibbles of AL and AH, the instruction will also convert the result of
  164.   adding two ASCII numbers, that is the ASCII characters representing
  165.   digits.  However, the converted result will be in unpacked BCD, not in
  166.   ASCII.
  167.  
  168.   ┌────────────────────────────────────────────────────────────────────────┐
  169.   │ 0011 0111                                                              │
  170.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  171.   │ AAA                 │ AAA                    │ 88/86  8                │
  172.   │                     │                        │   286  3                │
  173.   │                     │                        │   386  4                │
  174.   │                     │                        │   486  3                │
  175.   │                     │                        │ Pentm  3                │
  176.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  177.  
  178. ───────────────────────────────────────────────────────────────────────────────
  179. ADC              Add with Carry                      Flags: O D I T S Z A P C
  180.                                                             *       * * * * *
  181.  
  182. SYNTAX:
  183.   ADC      destination,source
  184.  
  185. LOGIC:
  186.   IF CF = 1 THEN
  187.      destination  destination + source + 1
  188.   ELSE
  189.      destination  destination + source
  190.   ENDIF
  191.  
  192.        This instruction adds together the two operands and the value of the
  193.   carry flag and stores the result in the destination operand.  This is
  194.   usually used to perform "multi-element addition" in order to add
  195.   quantities that are larger than the largest operand supported by the
  196.   processor.
  197.  
  198.        In multi-element addition, the quantities are added using multiple
  199.   add operations that start with the least significant portion (byte, word
  200.   or doubleword) of the quantities and proceed to the most significant
  201.   portion. The first addition is performed with a regular ADD instruction
  202.   (or ADC if the carry flag is previously cleared) and the remaining
  203.   additions use the ADC instruction.
  204.  
  205.        Note: The quantities to be added can be either signed or unsigned.
  206.  
  207. EXAMPLE
  208.        This example adds the 32 bit number in DX:AX to the 32 bit number in
  209.   CX:BX and stores the result in DX:AX.
  210.  
  211.            ADD     AX,BX                         ; Add least significant word.
  212.            ADC     DX,CX                         ; Add most significant word with carry.
  213.  
  214.        This example performs a multi-element add of two operands specified
  215.   by pointers in SI and DI and whose length is specified in CX.  This
  216.   example relies on the fact that when SI is adjusted with an INC
  217.   instruction, the carry flag is not affected.  This is probably the main
  218.   reason that INC and DEC do not update the carry flag.
  219.  
  220.            CLC                                   ; Clear carry for first add.
  221.  
  222. ADDTOP:    MOV     AL,[DI]                       ; Get next destination byte.
  223.            ADC     AL,[SI]                       ; Add on next source byte.
  224.            STOSB                                 ; Store result
  225.            INC     SI                            ; Point to next source byte.
  226.            LOOP    ADDTOP                        ; Loop back for next byte, if any.
  227.  
  228.   ┌────────────────────────────────────────────────────────────────────────┐
  229.   │ 0001 00,d,w   mod,reg,r/m   0, 2, or 4 byte displacement               │
  230.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  231.   │ ADC reg,reg         │ ADC DX,CX              │ 88/86  3                │
  232.   │                     │                        │   286  2                │
  233.   │                     │                        │   386  2                │
  234.   │                     │                        │   486  1                │
  235.   │                     │                        │ Pentm  1                │
  236.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  237.   │ ADC mem,reg         │ ADC NUMBER,CL          │ 88/86  16+EA            │
  238.   │                     │                        │  WD88  24+EA            │
  239.   │                     │                        │   286  7                │
  240.   │                     │                        │   386  7                │
  241.   │                     │                        │   486  3                │
  242.   │                     │                        │ Pentm  3                │
  243.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  244.   │ ADC reg,mem         │ ADC CL,NUMBER          │ 88/86  9+EA             │
  245.   │                     │                        │  WD88  13+EA            │
  246.   │                     │                        │   286  7                │
  247.   │                     │                        │   386  6                │
  248.   │                     │                        │   486  2                │
  249.   │                     │                        │ Pentm  2                │
  250.   ├─────────────────────┴────────────────────────┴─────────────────────────┤
  251.   │ 1000 00,s,w   mod,010,r/m   0, 2, or 4 byte displacement               │
  252.   │ 1, 2, or 4 byte immediate data                                         │
  253.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  254.   │ ADC reg,immed       │ ADC BX,1992            │ 88/86  4                │
  255.   │                     │                        │   286  3                │
  256.   │                     │                        │   386  2                │
  257.   │                     │                        │   486  1                │
  258.   │                     │                        │ Pentm  1                │
  259.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  260.   │ ADC mem,immed       │ ADC NUMBER,DX          │ 88/86  17+EA            │
  261.   │                     │                        │  WD88  23+EA            │
  262.   │                     │                        │   286  7                │
  263.   │                     │                        │   386  7                │
  264.   │                     │                        │   486  3                │
  265.   │                     │                        │ Pentm  3                │
  266.   ├─────────────────────┴────────────────────────┴─────────────────────────┤
  267.   │ 0001 010,w   1, 2, or 4 byte immediate data                            │
  268.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  269.   │ ADC accum,immed     │ ADC AX,1992            │ 88/86  4                │
  270.   │                     │                        │   286  3                │
  271.   │                     │                        │   386  2                │
  272.   │                     │                        │   486  1                │
  273.   │                     │                        │ Pentm  1                │
  274.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  275.  
  276. ───────────────────────────────────────────────────────────────────────────────
  277. BTC              Bit Test and Complement             Flags: O D I T S Z A P C
  278.                                                                             *
  279.  
  280. SYNTAX:
  281.   BTC      source,bitnum
  282.  
  283. LOGIC:
  284.   CF  BIT(bitnum,source)
  285.   BIT(bitnum,source)  NOT BIT(bitnum,source)
  286.  
  287.        This instruction copies the bit specified by bitnum from the source
  288.   operand to the carry flag, then complements (inverts) the specified bit.
  289.   That is, the carry flag is set if the specified bit is set, otherwise it
  290.   is cleared and then the specified bit is switched to its other value. Bits
  291.   in an operand are numbered from zero starting with the low (least
  292.   significant) bit.
  293.  
  294.        Since the destination can be either 16 or 32 bits, one would expect
  295.   bitnum to contain only values from 0 to 15 or 0 to 31.  Actually, the
  296.   instruction can handle larger bit numbers.  If the bit number is an
  297.   immediate (byte) value, or the destination is a register, then the bit
  298.   tested is the bit number modulo the number of bits in the destination
  299.   operand.  For example,
  300.  
  301.            BTC     AX,16
  302.  
  303.   will test bit 1, since 16 MOD 16 is 1.  However, if the destination is a
  304.   memory location and the bit number is in a register, then the instruction
  305.   will treat the memory location as a 2^16 (or 2^32) bit operand and will
  306.   test the appropriate bit in one of the successive words (or doublewords).
  307.   In this case, the bit number operand can be considered to contain two
  308.   fields.  One specifies the bit to be tested.  The other specifies a
  309.   displacement from the destination to the memory location to be tested.
  310.   The field specifying the bit to be tested occupies the low 4 bits for a
  311.   word destination and 5 bits for a double word destination.  The
  312.   displacement occupies rest of the field.  The memory location tested is
  313.   the specified effective address plus an additional displacement calculated
  314.   from
  315.  
  316.        2*(bitnum DIV 16)
  317.  
  318.   for a word operand or
  319.  
  320.        4*(bitnum DIV 32)
  321.  
  322.   for a doubleword operand.  Thus the instructions
  323.  
  324.            MOV     AX,00010011Y
  325.            MOV     BX,100H                       ; Get pointer to 100H.
  326.            BTC     WPTR [BX],AX
  327.  
  328.   will test bit 3 of the word at address 102H, because the low 4 bits
  329.   contain a 3 and the high 12 bits contain a 1.
  330.  
  331.        This function is available only on 80386 and later processors.
  332.  
  333.   ┌────────────────────────────────────────────────────────────────────────┐
  334.   │ 0000 1111   1011 1011   mod,reg,r/m   0, 2, or 4 byte displacement     │
  335.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  336.   │ BTC reg16,reg16     │ BTC AX,CX              │ 88/86  N/A              │
  337.   │ BTC reg32,reg32     │ BTC EAX,ECX            │   286  N/A              │
  338.   │                     │                        │   386  6                │
  339.   │                     │                        │   486  6                │
  340.   │                     │                        │ Pentm  7                │
  341.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  342.   │ BTC mem16,reg16     │ BTC BIFFLD,AX          │ 88/86  N/A              │
  343.   │ BTC mem32,reg32     │ BTC BITFLD,EAX         │   286  N/A              │
  344.   │                     │                        │   386  13               │
  345.   │                     │                        │   486  13               │
  346.   │                     │                        │ Pentm  13               │
  347.   ├─────────────────────┴────────────────────────┴─────────────────────────┤
  348.   │ 0000 1111   1011 1010   mod,111,r/m   0, 2, or 4 byte displacement     │
  349.   │ 1 byte immediate data                                                  │
  350.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  351.   │ BTC reg16,immed8    │ BTC AX,3               │ 88/86  N/A              │
  352.   │ BTC reg32,immed8    │ BTC EAX,3              │   286  N/A              │
  353.   │                     │                        │   386  6                │
  354.   │                     │                        │   486  6                │
  355.   │                     │                        │ Pentm  7                │
  356.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  357.   │ BTC mem16,immed8    │ BTC BIFFLD,4           │ 88/86  N/A              │
  358.   │ BTC mem32,immed8    │ BTC BITFLD,4           │   286  N/A              │
  359.   │                     │                        │   386  8                │
  360.   │                     │                        │   486  8                │
  361.   │                     │                        │ Pentm  8                │
  362.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  363.  
  364. ───────────────────────────────────────────────────────────────────────────────
  365. CMPSB            Compare String Byte                 Flags: O D I T S Z A P C
  366.                                                             *       * * * * *
  367.  
  368. SYNTAX:
  369.   CMPSB
  370.  
  371. LOGIC:
  372.   Flags set according to result of mem8[DS:SI] - mem8[ES:DI]
  373.   IF DF = 0 THEN
  374.      SI  SI + 1
  375.      DI  DI + 1
  376.   ELSE
  377.      SI  SI - 1
  378.      DI  DI - 1
  379.   ENDIF
  380.  
  381.        This instruction compares two memory locations by setting the flags
  382.   as if the byte at [ES:DI] were subtracted from the byte at [DS:SI].
  383.   Neither memory location is altered by this operation.  The destination
  384.   operand must be in the extra segment (ES), and the source should be in the
  385.   data segment (DS) unless the instruction is proceeded by a segment
  386.   override.  Following the comparison, SI and DI are incremented (or
  387.   decremented if the direction flag is set) by 1, in preparation for testing
  388.   the next (or previous) memory locations.
  389.  
  390.        The conditional repeat prefixes may be used to compare two memory
  391.   buffers.  This is used to determine whether or not two memory buffers are
  392.   identical.  It can also be used to locate where the buffers are same or
  393.   where they are different.
  394.  
  395. EXAMPLE:
  396.        The following example determines the first memory locations where two
  397.   buffers are different.
  398.  
  399.           CLD                          ; Increment string pointers.
  400.           MOV      SI,OFFSET BUF1      ; Get pointer to 1st buffer.
  401.           MOV      DI,OFFSET BUF2      ; Get pointer to 2nd buffer.
  402.           MOV      CX,BUFLEN           ; Load counter with length of buffers.
  403.           REPZ     CMPSB               ; Look for 1st mismatch.
  404.           JZ       IDENTICAL           ; Abort if buffers are identical.
  405.           DEC      SI                  ; Point back to first bytes that
  406.           DEC      DI                  ; were different.
  407.           * * *
  408.  
  409.        The following example determines the last memory locations where two
  410.   buffers are the same.
  411.  
  412.           STD                          ; Decrement string pointers.
  413.           MOV      SI,OFFSET BUF1+BUFLEN-1 ; Point to end of 1st buffer.
  414.           MOV      DI,OFFSET BUF2+BUFLEN-1 ; Point to end of 2nd buffer.
  415.           REPNZ    CMPSB               ; Look for 1st match.
  416.           JNZ      DIFFERENT           ; Abort, if completely different.
  417.           INC      SI                  ; Point back to first bytes
  418.           INC      DI                  ; that were the same.
  419.           * * *
  420.  
  421.   ┌────────────────────────────────────────────────────────────────────────┐
  422.   │ 1010 0010                                                              │
  423.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  424.   │ CMPSB               │ CMPSB                  │ 88/86  22               │
  425.   │                     │                        │   286  8                │
  426.   │                     │                        │   386  10               │
  427.   │                     │                        │   486  8                │
  428.   │                     │                        │ Pentm  5                │
  429.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  430.   │ REPZ CMPSB          │ REPZ CMPSB             │ 88/86  9+22n            │
  431.   │                     │                        │   286  5+9n             │
  432.   │                     │                        │   386  5+9n             │
  433.   │                     │                        │   486  7+7n  5 when n=0 │
  434.   │                     │                        │ Pentm  9+4n  7 when n=0 │
  435.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  436.   │ REPNZ CMPSB         │ REPNZ CMPSB            │ 88/86  9+22n            │
  437.   │                     │                        │   286  5+9n             │
  438.   │                     │                        │   386  5+9n             │
  439.   │                     │                        │   486  7+7n  5 when n=0 │
  440.   │                     │                        │ Pentm  8+4n  7 when n=0 │
  441.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  442.  
  443. ───────────────────────────────────────────────────────────────────────────────
  444. CPUID            Identify Processor                  Flags: O D I T S Z A P C
  445.                                                                               
  446.  
  447. SYNTAX:
  448.   CPUID
  449.  
  450. LOGIC:
  451.   IF EAX > MAX_CPUID_FCT THEN
  452.      EAX  undefined.
  453.      EBX  undefined.
  454.      ECX  undefined.
  455.      EDX  undefined.
  456.   ELSEIF EAX = 0 THEN
  457.      EAX  MAX_CPUID_FCT
  458.      EBX  Vendor identification string characters 1-4.
  459.      ECX  Vendor identification string characters 5-8.
  460.      EDX  Vendor identification string characters 9-12.
  461.   ELSEIF EAX = 1 THEN
  462.      EAX  Processor ID.
  463.      EBX  Reserved.
  464.      ECX  Reserved.
  465.      EDX  Feature flags.
  466.   ELSE
  467.      No other cases possible on chips up to the Pentium.  But other
  468.      processors and manufacturers will support additional function numbers.
  469.   ENDIF
  470.  
  471.        This instruction is used to determine the make, model, family, and
  472.   features of a processor.  Unfortunately, this instruction is supported
  473.   only on 586 and later processors.  This instruction will probably provide
  474.   additional information on future processors.  When the instruction is
  475.   performed, EAX contains a function number that identifies the type of
  476.   information to be returned.  Currently only two function numbers (0 and 1)
  477.   are supported, but future processors are expected to support more.  To
  478.   insure backward compatibility, function 0 returns the maximum function
  479.   number recognized by the processor, thus a program can avoid using
  480.   invalid function numbers.
  481.  
  482.        When the function zero is executed, EAX returns the highest function
  483.   number supported.  EBX:ECX:EDX returns a 12 character ASCII string
  484.   identifying the processor's manufacturer.  The first digit of the 4 digit
  485.   sub-strings is stored in the low byte.  Thus, if the registers are stored
  486.   in memory as doublewords, the appropriate name is formed.  For example.
  487.  
  488.            MOV     CPUMAKNAM,EBX
  489.            MOV     CPUMAKNAM+4,ECX
  490.            MOV     CPUMAKNAM+8,EDX
  491.  
  492.            *   *   *
  493.  
  494. CPUMAKNAM  DD      0,0,0
  495.  
  496.   The pentium processor and other Intel chips will return
  497.  
  498.   EBX = 756E6547H
  499.   ECX = 49656E69H
  500.   EDX = 6C65746EH
  501.  
  502.   which forms "GenuineIntel".
  503.  
  504.        When function one is executed.  EAX returns information that
  505.   identifies the model of the processor.  The low four bytes are the
  506.   stepping ID of the processor.  From intel's documentation, I have inferred
  507.   that the processor's step is indicated in BCD.  Thus the A stepping is
  508.   indicated by a 0AH, the B stepping by a 0BH.  The next four bits specify
  509.   the model (for example, if is the processor an SX or DX chip).  These bits
  510.   appear to be interpreted as a binary number with the first model numbered
  511.   as 1.  The next four bits, specify the processor's family.  A 586 chip
  512.   returns a binary 5 in these bits and a 686 chip will, presumably, return a
  513.   a 6.  The remainder of EAX is reserved.
  514.  
  515.  
  516.    31               12 11 8 7  4 3  0
  517.   ┌───────────────────┬────┬────┬────┐
  518.   │Reserved           │Fmly│Modl│Step│
  519.   └───────────────────┴─┬──┴─┬──┴─┬──┘
  520.                         │    │    └─── Stepping ID.
  521.                         │    └──────── Model.
  522.                         └───────────── Family.
  523.  
  524.        When function one is executed, EDX returns information that
  525.   identifies the processor's features.  If bit 0 is set, the chip contains a
  526.   built-in floating point unit.  Bit 7 indicates if the processor supports
  527.   the machine check exception.  If bit 8 is set, the processor supports the
  528.   CMPXCHG8B instruction.  The remaining bits are either reserved or their
  529.   interpretation is considered proprietary of Intel inc. and may not be
  530.   disclosed to the public.
  531.  
  532.   ┌────────────────────────────────────────────────────────────────────────┐
  533.   │ 0000 1111   1010 0010                                                  │
  534.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  535.   │ CPUID               │ CPUID                  │ 88/86  N/A              │
  536.   │                     │                        │   286  N/A              │
  537.   │                     │                        │   386  N/A              │
  538.   │                     │                        │   486  N/A              │
  539.   │                     │                        │ Pentm  14               │
  540.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  541.  
  542. '───────────────────────────────────────────────────────────────────────────────
  543. DEC              Decrement                           Flags: O D I T S Z A P C
  544.                                                             *       * * * *
  545.  
  546. SYNTAX:
  547.   DEC      destination
  548.  
  549. LOGIC:
  550.   destination  destination - 1
  551.  
  552.        This instruction decrements the destination operand by one.  This
  553.   instruction is usually preferable to subtracting one from an operand with
  554.   the SUB instruction because it is shorter.
  555.  
  556.        Note that, unlike the SUB instruction, this instruction does not
  557.   affect the carry flag.  This allows the instruction to be used to
  558.   decrement pointers without affecting the carry in multi-element arithmetic
  559.   routines.
  560.  
  561.   ┌────────────────────────────────────────────────────────────────────────┐
  562.   │ 1111 111,w   mod,001,r/m   0, 2, or 4 byte displacement                │
  563.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  564.   │ DEC reg8            │ DEC BL                 │ 88/86  3                │
  565.   │                     │                        │   286  2                │
  566.   │                     │                        │   386  2                │
  567.   │                     │                        │   486  1                │
  568.   │                     │                        │ Pentm  1                │
  569.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  570.   │ DEC mem             │ DEC COUNT              │ 88/86  15+EA            │
  571.   │                     │                        │  WD88  23+EA            │
  572.   │                     │                        │   286  7                │
  573.   │                     │                        │   386  6                │
  574.   │                     │                        │   486  3                │
  575.   │                     │                        │ Pentm  3                │
  576.   ├─────────────────────┴────────────────────────┴─────────────────────────┤
  577.   │ 0100 1,reg                                                             │
  578.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  579.   │ DEC reg16           │ DEC AX,NUMBER          │ 88/86  3                │
  580.   │ DEC reg32           │ DEC ECX                │   286  2                │
  581.   │                     │                        │   386  2                │
  582.   │                     │                        │   486  1                │
  583.   │                     │                        │ Pentm  1                │
  584.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  585.  
  586. '───────────────────────────────────────────────────────────────────────────────
  587. ENTER            High Level Procedure Enter          Flags: O D I T S Z A P C
  588.  
  589.  
  590. SYNTAX:
  591.   ENTER    localsize,nesting
  592.  
  593. LOGIC:
  594.   IF operandsize = 16 BIT THEN
  595.      PUSH(BP)
  596.      saveptr  BP
  597.      FOR i = 1 TO nesting DO
  598.         BP  BP - 2
  599.         PUSH([BP])
  600.      ENDFOR
  601.      PUSH(saveptr)
  602.      BP  saveptr
  603.      SP  SP - localsize
  604.   ELSE
  605.      PUSH(EBP)
  606.      saveptr  EBP
  607.      FOR i = 1 TO nesting DO
  608.         EBP  EBP - 4
  609.         PUSH([EBP])
  610.      ENDFOR
  611.      PUSH(saveptr)
  612.      EBP  saveptr
  613.      ESP  ESP - localsize
  614.   ENDIF
  615.  
  616.        This instruction can be used to create a stack frame.  The first
  617.   operand is the size of the local variables (in bytes) to be allocated on
  618.   the stack.  The second parameter is the number of stack frame pointers
  619.   from the nested calling routines that the procedure will need (or any
  620.   procedure it calls will need).
  621.  
  622.        The instruction works as follows, BP is pushed to save the stack
  623.   frame of the calling procedure.  Then the routine copies the specified
  624.   number of stack frame pointers from the calling procedure.  It assumes
  625.   that the stack frame pointers were allocated in the calling procedure at
  626.   the first negative offsets from the base pointer and it allocates them in
  627.   the new procedure at the first negative offsets from the base pointer.
  628.   Next it pushes a copy of the new stack frame pointer (so that any
  629.   sub-routines called can get this routine's stack frame pointer.  Finally
  630.   it decrements the stack pointer by size of the local variables to be
  631.   allocated.
  632.  
  633.        The stack frame looks like this.
  634.  
  635.                                         Offset           Length
  636.               ┌──────────────────┐
  637.          Low  │ Local Variables. │ [BP] -2*nesting-4   localsize
  638.              │                  │ [EBP]-4*nesting-8   localsize
  639.           │   ├──────────────────┤
  640.           │   │ Saved Current    │ [BP] -2*nesting-2   2
  641.           │   │ Frame pointer.   │ [EBP]-4*nesting-4   4
  642.           │   ├──────────────────┤
  643.           │   │ Calling Routines'│ [BP] +0             2*nesting
  644.           │   │ Frame Pointers.  │ [EBP]+0             4*nesting
  645.           │   ├──────────────────┤
  646.           │   │ Saved Previous   │ [BP] +2             2
  647.           │   │ Frame Pointer.   │ [EBP]+4             4
  648.           │   ├──────────────────┤
  649.           │   │ Address to be    │ [BP] +4             2 or 4
  650.           │   │ RETurned to.     │ [EBP]+8             2 or 4
  651.           │   ├──────────────────┤
  652.              │ Parameters to    │ [BP] +6  or +8      Set by caller
  653.          High │ Current Routine. │ [EBP]+10 or +12     Set by caller
  654.               └──────────────────┘
  655.  
  656.        After the instruction, the stack frame pointer BP, points to the
  657.   previous routine's saved stack frame pointer.  At negative offsets from BP
  658.   there are the stack frame pointers of the calling routines, which can be
  659.   used to access the local variables of the calling routines.  The highest
  660.   routine's stack frame pointer is at [BP]-2 and the calling routine's
  661.   pointer is at [BP]-2*nesting (in 16 bit mode).  The local variables, if
  662.   any are allocated, start at [BP]-2*nesting-2.  The address of the calling
  663.   routine's instruction to RET is at [BP]+2.  Then at [BP]+4 (or at [BP]+6
  664.   if this is a FAR routine) there are the parameters placed on the stack by
  665.   the calling routine.
  666.  
  667.        In timings with a nesting value greater than 1, n represents the
  668.   nesting level.
  669.  
  670.   ┌────────────────────────────────────────────────────────────────────────┐
  671.   │ 1100 1000   2 byte localsize   1 byte nesting                          │
  672.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  673.   │ ENTER immed16,0     │ ENTER 6,0              │ 88/86  N/A              │
  674.   │                     │                        │   286  11               │
  675.   │                     │                        │   386  10               │
  676.   │                     │                        │   486  14               │
  677.   │                     │                        │ Pentm  11               │
  678.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  679.   │ ENTER immed16,1     │ ENTER 4,1              │ 88/86  N/A              │
  680.   │                     │                        │   286  15               │
  681.   │                     │                        │   386  12               │
  682.   │                     │                        │   486  17               │
  683.   │                     │                        │ Pentm  15               │
  684.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  685.   │ ENTER immed16,immed8│ ENTER 10,4             │ 88/86  N/A              │
  686.   │                     │                        │   286  16+4*(n-1)       │
  687.   │                     │                        │   386  15+4*(n-1)       │
  688.   │                     │                        │   486  17+3*n           │
  689.   │                     │                        │ Pentm  15+2*n           │
  690.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  691.  
  692. ───────────────────────────────────────────────────────────────────────────────
  693. INVD             Invalidate a Page in the TLB        Flags: O D I T S Z A P C
  694.  
  695.  
  696. SYNTAX:
  697.   INVLPG   destination
  698.  
  699. LOGIC:
  700.   Invalidate the Translation Lookaside Buffer entries for the specified
  701.   linear address, if any entries exists.
  702.  
  703.        This instruction is used to invalidate the Translation Lookaside
  704.   Buffer (TLB) entries for the page that the specified memory address
  705.   resides in.  The TLB stores the linear address to physical address
  706.   mappings of some of the more recent pages accessed.  When the processor
  707.   needs to access memory in a page that has an entry in TLB the processor
  708.   can quickly determine the physical address without having to look-up
  709.   information in the page directories and page tables.  However if a page
  710.   mapping is altered, for example if a page is swapped out or moved to a new
  711.   location, the page's entry in TLB (if there is one) will not be updated
  712.   even though the page table entry (in memory) is updated.  This instruction
  713.   is used to invalidate any entries in the TLB for the remapped page.  Thus,
  714.   when the processor next attempts to access the page, it will not be in the
  715.   TLB and the processor will be forced to find the information using the new
  716.   information in the page directory and page tables.
  717.  
  718.        The operand to INVLPG must be a linear memory address.  The
  719.   instruction encoding would suggest a register operand could be specified.
  720.   However, registers don't reside in page's, thus this instruction makes no
  721.   sense with a register operand.  An invalid opcode exception will occur if
  722.   the processor encounters this instruction with a register operand
  723.   specified.
  724.  
  725.        This instruction is intended to be used only by the operating system.
  726.   The paging mechanism is transparent to application programs (except for
  727.   cases where an application must implement paging because the operating
  728.   system does not).
  729.  
  730.        The current privilege level (CPL) must be 0 or this instruction will
  731.   cause a general protection fault.
  732.  
  733.        In the timings listed below, the NH timings are for when no entries
  734.   for the page are found in the TLB.
  735.  
  736.   ┌────────────────────────────────────────────────────────────────────────┐
  737.   │ 0000 1111   0000 0001   mod,111,r/m                                    │
  738.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  739.   │ INVLPG              │ INVLPG                 │    88  N/A              │
  740.   │                     │                        │    86  N/A              │
  741.   │                     │                        │   286  N/A              │
  742.   │                     │                        │   386  N/A              │
  743.   │                     │                        │   486  12     NH=11     │
  744.   │                     │                        │ Pentm  25               │
  745.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  746.  
  747. ───────────────────────────────────────────────────────────────────────────────
  748. JA               Jump If Above                       Flags: O D I T S Z A P C
  749.  
  750.  
  751. SYNTAX:
  752.   JA       label
  753.  
  754. LOGIC:
  755.   IF (CF = 0) AND (ZF = 0) THEN
  756.      IF addresssize = 16 BIT THEN
  757.         IF shortjump THEN
  758.            IP  IP + SIGNEXTEND(disp8)
  759.         ELSE
  760.            IP  IP + disp16
  761.         ENDIF
  762.      ELSE
  763.         IF shortjump THEN
  764.            EIP  EIP + SIGNEXTEND(disp8)
  765.         ELSE
  766.            EIP  EIP + disp32
  767.         ENDIF
  768.      ENDIF
  769.   ENDIF
  770.  
  771.        This instruction tests if the carry flag and zero flag are both
  772.   clear.  If so, control is transferred to the instruction at the specified
  773.   label, otherwise the processor continues with the next instruction.
  774.  
  775.        This instruction is usually used to test the flags set by a CMP or
  776.   SUB of two unsigned numbers.  It will transfer control to the specified
  777.   label if the destination operand was above (greater than) the source
  778.   operand.
  779.  
  780.        JNBE is an alternate mnemonic for the same instruction.
  781.  
  782.        This instruction should be used after unsigned numbers are tested.
  783.   The corresponding mnemonic for signed numbers is JG.
  784.  
  785.   ┌────────────────────────────────────────────────────────────────────────┐
  786.   │ 0111 0111   1 byte displacement                                        │
  787.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  788.   │ JA short label      │ JA ABORT               │    88  16    NJ=4       │
  789.   │                     │                        │    86  16    NJ=4       │
  790.   │                     │                        │   286  7+m   NJ=3       │
  791.   │                     │                        │   386  7+m   NJ=3       │
  792.   │                     │                        │   486  3     NJ=1       │
  793.   │                     │                        │ Pentm  1     NJ=1       │
  794.   ├─────────────────────┴────────────────────────┴─────────────────────────┤
  795.   │ 0000 1111   1000 0111   2 or 4 byte displacement                       │
  796.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  797.   │ JA near label       │ JA PRGEND              │    88  N/A              │
  798.   │                     │                        │    86  N/A              │
  799.   │                     │                        │   286  N/A              │
  800.   │                     │                        │   386  7+m   NJ=3       │
  801.   │                     │                        │   486  3     NJ=1       │
  802.   │                     │                        │ Pentm  1     NJ=1       │
  803.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  804.  
  805. ───────────────────────────────────────────────────────────────────────────────
  806. LEA              Load Effective Address              Flags: O D I T S Z A P C
  807.                                                                               
  808.  
  809. SYNTAX:
  810.   LEA      dstreg,address
  811.  
  812. LOGIC:
  813.      dstreg  EA
  814.  
  815.        This instruction loads a 16 or 32 bit register with an effective
  816.   address value.  This is usually used to convert an effective address
  817.   involving two or more elements, like a base and index register, to an
  818.   simple address contained in only one register.  For example, the code
  819.  
  820.            LEA     SI,[BX+SI]+100
  821.  
  822.   loads into SI, the address specified by [BX+SI]+100, that is, it adds BX,
  823.   SI, and 100 stores the result in SI.  This instruction can be used on
  824.   simpler effective addresses, like those involving only a pointer register
  825.   or a memory location however, it is usually not necessary to use LEA in
  826.   these case.  In fact some assemblers will look for such cases and output
  827.   faster or shorter instructions that produce the same result.  For example,
  828.  
  829.            LEA     DI,[SI]
  830.  
  831.   can simply be coded as
  832.  
  833.            MOV     DI,SI
  834.  
  835.   and
  836.  
  837.            LEA     AX,COUNT
  838.            . . .
  839. COUNT      DW      0
  840.  
  841.   can simply be coded as
  842.  
  843.            MOV     AX,OFFSET COUNT
  844.  
  845.        Although it is not intended to do so, this instruction can be used in
  846.   certain cases to take short cuts in arithmetic calculations.  For example,
  847.   it can be used to add BX and SI and store the result in AX in one
  848.   instruction, like
  849.  
  850.            LEA     AX,[BX+SI]
  851.  
  852.   rather than the standard two instructions
  853.  
  854.            MOV     AX,BX
  855.            ADD     AX,SI
  856.  
  857.   Note that this type of optimization can only be used when the flags do not
  858.   need to be set from the result.
  859.  
  860.        Note also that the timing for this instruction on a 80486 is 1 clock
  861.   cycle unless an index register is used, in which case an extra clock cycle
  862.   may be required.
  863.  
  864.   ┌────────────────────────────────────────────────────────────────────────┐
  865.   │ 1000 1101   mod,reg,r/m   0, 2, or 4 byte displacement                 │
  866.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  867.   │ LEA reg16,mem       │ LEA AX,[BX+4]          │ 88/86  2+EA             │
  868.   │                     │                        │   286  3                │
  869.   │                     │                        │   386  2                │
  870.   │                     │                        │   486  1 or 2           │
  871.   │                     │                        │ Pentm  1                │
  872.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  873.   │ LEA reg32,mem       │ LEA EBX,[BX+SI]+TBLLEN │ 88/86  N/A              │
  874.   │                     │                        │   286  N/A              │
  875.   │                     │                        │   386  2                │
  876.   │                     │                        │   486  1 or 2           │
  877.   │                     │                        │ Pentm  1                │
  878.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  879.  
  880. ───────────────────────────────────────────────────────────────────────────────
  881. MOVSX            Move With Sign-Extend               Flags: O D I T S Z A P C
  882.  
  883.  
  884. SYNTAX:
  885.   MOVSX    destination,source
  886.  
  887. LOGIC:
  888.   destination  SIGNEXTEND(source)
  889.  
  890.        This instruction is used to load a register with a value from memory
  891.   or another register whose size is smaller than the register to be loaded.
  892.   That is, it can be used to load a byte value into a word or doubleword
  893.   register or load a word value into a doubleword.  This instruction will
  894.   treat the value to be loaded as a signed number and sign extend it to the
  895.   size of the register to be loaded.  This same function can be accomplished
  896.   by loading the value into a smaller register and using the sign extension
  897.   instructions.  However, the move with sign extend instruction will
  898.   generate shorter, faster code and is more flexible in register usage than
  899.   the sign extension instructions.
  900.  
  901.        If the value to be loaded is not signed, the move with zero extend
  902.   instruction (MOVZX) should be used instead.
  903.  
  904.   ┌────────────────────────────────────────────────────────────────────────┐
  905.   │ 0000 1111   1011 111,w   mod,reg,r/m   0, 2, or 4, byte displacement   │
  906.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  907.   │ MOVSX reg,reg       │ MOVSX CX,AL            │ 88/86  N/A              │
  908.   │                     │                        │   286  N/A              │
  909.   │                     │                        │   386  3                │
  910.   │                     │                        │   486  3                │
  911.   │                     │                        │ Pentm  3                │
  912.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  913.   │ MOVSX reg,mem       │ MOVSX EAX,BYTE PTR [BX]│ 88/86  N/A              │
  914.   │                     │                        │   286  N/A              │
  915.   │                     │                        │   386  6                │
  916.   │                     │                        │   486  3                │
  917.   │                     │                        │ Pentm  3                │
  918.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  919.  
  920. ───────────────────────────────────────────────────────────────────────────────
  921. NOP              No Operation                        Flags: O D I T S Z A P C
  922.                                                                               
  923.  
  924. SYNTAX:
  925.   NOP
  926.  
  927. LOGIC:
  928.   IF operandsize = 16 bit THEN
  929.      AX  AX
  930.   ELSE
  931.      EAX  EAX
  932.   ENDIF
  933.  
  934.        This instruction makes no effective changes to the processor's
  935.   internal state (registers or flags) except that the instruction pointer is
  936.   updated to point to the next instruction.  The instruction is usually used
  937.   for two purposes.  First, when debugging, it can be used to overwrite
  938.   instructions, effectively removing them from the code.  Second, when the
  939.   assembler is instructed to align an instruction to a particular boundary,
  940.   it will use NOPs to provide padding after a previous instruction.
  941.  
  942.        There is no actual NOP instruction, the NOP mnemonic is usually
  943.   coded as XCHG AX,AX, which is a one byte instruction that causes no
  944.   effective change to the processor.  Most debuggers will display the NOP
  945.   mnemonic when they disassemble XCHG AX,AX, regardless of which instruction
  946.   was specified in the source code.
  947.  
  948.        When the assembler aligns instructions, it may use instructions
  949.   other than XCHG AX,AX to minimize the padding's execution time.  For
  950.   example, the assembler could code XCHG BX,BX to provide two bytes of
  951.   padding that would execute in less time than two XCHG AX,AX instructions.
  952.   Intel recommends the following methods of coding NOPs longer than one byte
  953.   and that will execute in only one clock cycle.  Of course it may be
  954.   necessary to use more than one instruction to provide padding to certain
  955.   lengths.
  956.  
  957.   MOV REG,REG   ; 2 bytes.   The source and destination must be the same.
  958.   LEA REG,[REG] ; 3 bytes.   The source and destination must be the same.
  959.   LEA EAX,[EAX] ; 6 bytes.   On a 386 or later.
  960.  
  961.        Note that in the table below, the timing for the 486 is for the B and
  962.   later steppings of the processor.  The A-Step processors require 3 clock
  963.   cycles.
  964.  
  965.   ┌────────────────────────────────────────────────────────────────────────┐
  966.   │ 1001 0000                                                              │
  967.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  968.   │ NOP                 │ NOP                    │ 88/86  3                │
  969.   │                     │                        │   286  3                │
  970.   │                     │                        │   386  3                │
  971.   │                     │                        │   486  1                │
  972.   │                     │                        │ Pentm  1                │
  973.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  974.  
  975. ───────────────────────────────────────────────────────────────────────────────
  976. OR               Bitwise Logical OR                  Flags: O D I T S Z A P C
  977.                                                             0       * * ? * 0
  978.  
  979. SYNTAX:
  980.   OR       destination,source
  981.  
  982. LOGIC:
  983.   destination  destination || source
  984.  
  985.   ┌────────────────────────┐
  986.   │  OR Logic Truth Table  │
  987.   ├────────────────────────┤
  988.   │   p     q     p || q   │
  989.   ╞════════════════════════╡
  990.   │   0     0       0      │
  991.   │   0     1       1      │
  992.   │   1     0       1      │
  993.   │   1     1       1      │
  994.   └────────────────────────┘
  995.  
  996.        This instruction takes the bitwise logical OR of the source and
  997.   destination values and stores the result in the destination operand.  Each
  998.   bit of the result is set if the corresponding bits of either or both
  999.   operands were set, otherwise the bit is cleared.
  1000.  
  1001.        This instruction is often used to set specific bits in a bit field
  1002.   value while leaving the remaining bits unchanged.  The bit field value is
  1003.   ORed with a mask that has the bits to be set, set and the bits to be left
  1004.   alone cleared.
  1005.  
  1006.        This instruction can also be used to test if a register is zero.
  1007.   ORing a register with itself will set the zero flag if the register is
  1008.   zero and will leave the register unchanged.  This yields shorter code than
  1009.   comparing (CMP) the register with zero and, on some processors, this is
  1010.   faster as well.  Note that this can only be used to test whether or not a
  1011.   register is zero.  Since the carry and overflow flags are always cleared,
  1012.   it cannot be used to test if a register is greater than or less than
  1013.   zero.
  1014.  
  1015.   ┌────────────────────────────────────────────────────────────────────────┐
  1016.   │ 0000 10,d,w   mod,reg,r/m   0, 2, or 4 byte displacement               │
  1017.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1018.   │ OR reg,reg          │ OR AX,BX               │ 88/86  3                │
  1019.   │                     │                        │   286  2                │
  1020.   │                     │                        │   386  2                │
  1021.   │                     │                        │   486  1                │
  1022.   │                     │                        │ Pentm  1                │
  1023.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  1024.   │ OR reg,mem          │ OR DX,BITMSK           │ 88/86  16+EA            │
  1025.   │                     │                        │  WD88  24+EA            │
  1026.   │                     │                        │   286  7                │
  1027.   │                     │                        │   386  6                │
  1028.   │                     │                        │   486  3                │
  1029.   │                     │                        │ Pentm  2                │
  1030.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  1031.   │ OR mem,reg          │ OR BITFLD,EAX          │ 88/86  16+EA            │
  1032.   │                     │                        │  WD88  24+EA            │
  1033.   │                     │                        │   286  7                │
  1034.   │                     │                        │   386  6                │
  1035.   │                     │                        │   486  3                │
  1036.   │                     │                        │ Pentm  3                │
  1037.   ├─────────────────────┴────────────────────────┴─────────────────────────┤
  1038.   │ 1000 00,s,w   mod,001,r/m   0, 2, or 4 byte displacement   1, 2, 4     │
  1039.   │ 1, 2, or 4 byte immediate data                                         │
  1040.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1041.   │ OR reg,immed        │ OR AX,0FH              │ 88/86  4                │
  1042.   │                     │                        │   286  3                │
  1043.   │                     │                        │   386  2                │
  1044.   │                     │                        │   486  1                │
  1045.   │                     │                        │ Pentm  1                │
  1046.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  1047.   │ OR mem,immed        │ OR [BX],10101010B      │ 88/86  17+EA            │
  1048.   │                     │                        │  WD88  25+EA            │
  1049.   │                     │                        │   286  7                │
  1050.   │                     │                        │   386  7                │
  1051.   │                     │                        │   486  3                │
  1052.   │                     │                        │ Pentm  3                │
  1053.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  1054.  
  1055. ───────────────────────────────────────────────────────────────────────────────
  1056. PUSH             Push Value onto Stack               Flags: O D I T S Z A P C
  1057.  
  1058.  
  1059. SYNTAX:
  1060.   PUSH     source
  1061.  
  1062. LOGIC:
  1063.   IF stackaddrsize = 16 BIT THEN
  1064.      SP  SP - SIZEOF(source)
  1065.      IF SIZEOF(source) = 2 THEN
  1066.         mem16[SS:SP]  source
  1067.      ELSE
  1068.         mem32[SS:SP]  source
  1069.      ENDIF
  1070.   ELSE
  1071.      ESP  ESP - SIZEOF(source)
  1072.      IF SIZEOF(source) = 2 THEN
  1073.         mem16[SS:ESP]  source
  1074.      ELSE
  1075.         mem32[SS:ESP]  source
  1076.      ENDIF
  1077.   ENDIF
  1078.  
  1079.        This instruction is used to push a word or doubleword value onto the
  1080.   top of the stack.  The value to be pushed may come from a register or
  1081.   memory or may be immediate.
  1082.  
  1083.        Note that some processors in the 80x86 family adjust the stack
  1084.   pointer register before pushing the source and others push the source
  1085.   value and then adjust the stack pointer.  This difference is noticeable
  1086.   only when performing an operation like PUSH SP.  Since there is never a
  1087.   need to save the stack pointer on the stack, the difference is of little
  1088.   importance.  However, this difference is often used to help determine
  1089.   which processor a program is running on.
  1090.  
  1091.        Note that PUSH reg can be coded two ways, however, the PUSH mem/reg
  1092.   encoding is one byte longer, so it is not usually used to push registers.
  1093.  
  1094.   ┌────────────────────────────────────────────────────────────────────────┐
  1095.   │ 0101 0,reg                                                             │
  1096.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1097.   │ PUSH reg16          │ PUSH AX                │    86  11               │
  1098.   │                     │                        │    88  15               │
  1099.   │                     │                        │   286  3                │
  1100.   │                     │                        │   386  2                │
  1101.   │                     │                        │   486  1                │
  1102.   │                     │                        │ Pentm  1                │
  1103.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  1104.   │ PUSH reg32          │ PUSH EBX               │ 88/86  N/A              │
  1105.   │                     │                        │   286  N/A              │
  1106.   │                     │                        │   386  2                │
  1107.   │                     │                        │   486  1                │
  1108.   │                     │                        │ Pentm  1                │
  1109.   ├─────────────────────┴────────────────────────┴─────────────────────────┤
  1110.   │ 1111 1111   mod,110,r/m   0, 2, or 4 byte displacement                 │
  1111.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1112.   │ PUSH reg16          │ PUSH AX                │    86  11               │
  1113.   │                     │                        │    88  15               │
  1114.   │                     │                        │   286  3                │
  1115.   │                     │                        │   386  5                │
  1116.   │                     │                        │   486  4                │
  1117.   │                     │                        │ Pentm  1                │
  1118.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  1119.   │ PUSH reg32          │ PUSH ECX               │ 88/86  N/A              │
  1120.   │                     │                        │   286  N/A              │
  1121.   │                     │                        │   386  5                │
  1122.   │                     │                        │   486  4                │
  1123.   │                     │                        │ Pentm  1                │
  1124.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  1125.   │ PUSH mem16          │ PUSH WORD PTR [BX]     │    86  16+EA            │
  1126.   │                     │                        │    88  24+EA            │
  1127.   │                     │                        │   286  5                │
  1128.   │                     │                        │   386  5                │
  1129.   │                     │                        │   486  4                │
  1130.   │                     │                        │ Pentm  2                │
  1131.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  1132.   │ PUSH mem32          │ PUSH COUNTER           │ 88/86  N/A              │
  1133.   │                     │                        │   286  N/A              │
  1134.   │                     │                        │   386  5                │
  1135.   │                     │                        │   486  4                │
  1136.   │                     │                        │ Pentm  2                │
  1137.   ├─────────────────────┴────────────────────────┴─────────────────────────┤
  1138.   │ 00,sreg,110                                                            │
  1139.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1140.   │ PUSH sreg           │ PUSH DS                │    86  10               │
  1141.   │                     │ PUSH ES                │    88  14               │
  1142.   │                     │ PUSH SS                │   286  3                │
  1143.   │                     │ PUSH CS                │   386  2                │
  1144.   │                     │                        │   486  3                │
  1145.   │                     │                        │ Pentm  1                │
  1146.   ├─────────────────────┴────────────────────────┴─────────────────────────┤
  1147.   │ 0000 1111   10,sreg,001                                                │
  1148.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1149.   │ PUSH sreg           │ PUSH FS                │ 88/86  N/A              │
  1150.   │                     │ PUSH GS                │   286  N/A              │
  1151.   │                     │                        │   386  2                │
  1152.   │                     │                        │   486  3                │
  1153.   │                     │                        │ Pentm  1                │
  1154.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  1155.  
  1156. ───────────────────────────────────────────────────────────────────────────────
  1157. ROL              Rotate Left                         Flags: O D I T S Z A P C
  1158.                                                             *               *
  1159.  
  1160. SYNTAX:
  1161.   ROL      destination,count
  1162.  
  1163. LOGIC:
  1164.   IF Processor() = 8086 OR Processor() = 8088 THEN
  1165.      n  count
  1166.   ELSE
  1167.      n  count MOD 32
  1168.   ENDIF
  1169.   WHILE n > 0
  1170.      CF  BIT(8*SIZEOF(destination)-1,destination)
  1171.      SHL(destination,1)
  1172.      BIT(0,destination)  CF
  1173.      n  n - 1
  1174.   ENDWHILE
  1175.   IF count = 1 THEN
  1176.      IF BIT(8*SIZEOF(destination)-1,destination) = CF THEN
  1177.         OF  0
  1178.      ELSE
  1179.         OF  1
  1180.      ENDIF
  1181.   ELSE
  1182.      OF  undefined
  1183.   ENDIF
  1184.  
  1185.            ┌────────────────────┐
  1186.   ┌────┐   │   ┌─────────────┐   │
  1187.   │ CF ├──┴──┤ Destination ├──┘
  1188.   └────┘       └─────────────┘
  1189.  
  1190.        This instruction rotates the bits in the destination operand to the
  1191.   left by 1 and repeats the process the number of times specified by count.
  1192.   On each rotate, the value shifted out of the high bit is stored in the
  1193.   carry flag and is shifted into the low bit of the result.  For rotates
  1194.   with a count of 1, the overflow flag is set if the high bit's value
  1195.   changed and cleared otherwise.  The overflow flag is undefined for rotates
  1196.   with a count greater than 1.
  1197.  
  1198.        Note that the 8086 and 8088 processors allow count values up to 255.
  1199.   However, rotates never need to have count values greater than 15 (7 for
  1200.   byte destinations, 31 for doublewords).  Larger count values are
  1201.   unnecessary since bits will be rotated completely around the operand and
  1202.   back to their starting positions.  The 80286 and later processors limit
  1203.   the effective count to 31 by using only the low 5 bits of the specified
  1204.   count.  This was done to limit the amount of time that a pending interrupt
  1205.   will have to wait for the processor to complete an instruction.  The fact
  1206.   that the count is limited will have no affect on the result of shift
  1207.   instructions or on rotates that don't use the carry flag.  However,
  1208.   rotates through the carry with counts greater than 31 will produce
  1209.   different results on processors that limit the count.
  1210.  
  1211.        Note that the rotate by an immediate count instructions were added to
  1212.   the instruction set with the 80186 processor.  However, on some processors
  1213.   it is faster to perform multiple single-bit rotates than a single
  1214.   multi-bit rotate.
  1215.  
  1216.   ┌────────────────────────────────────────────────────────────────────────┐
  1217.   │ 1101 000,w   mod,000,r/m   0, 2, or 4 byte displacement                │
  1218.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1219.   │ ROL reg,1           │ ROL AX,1               │ 88/86  2                │
  1220.   │                     │                        │   286  2                │
  1221.   │                     │                        │   386  3                │
  1222.   │                     │                        │   486  3                │
  1223.   │                     │                        │ Pentm  1                │
  1224.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  1225.   │ ROL mem,1           │ ROL MEMWRD,1           │ 88/86  15+EA            │
  1226.   │                     │                        │  WD88  23+EA            │
  1227.   │                     │                        │   286  7                │
  1228.   │                     │                        │   386  7                │
  1229.   │                     │                        │   486  4                │
  1230.   │                     │                        │ Pentm  3                │
  1231.   ├─────────────────────┴────────────────────────┴─────────────────────────┤
  1232.   │ 1101 001,w   mod,000,r/m   0, 2, or 4 byte displacement                │
  1233.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1234.   │ ROL reg,CL          │ ROL CH,CL              │ 88/86  8+4n             │
  1235.   │                     │                        │   286  5+n              │
  1236.   │                     │                        │   386  3                │
  1237.   │                     │                        │   486  3                │
  1238.   │                     │                        │ Pentm  4                │
  1239.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  1240.   │ ROL mem,CL          │ ROL BYTE PTR [DI],CL   │ 88/86  20+EA+4n         │
  1241.   │                     │                        │  WD88  28+EA+4n         │
  1242.   │                     │                        │   286  8+n              │
  1243.   │                     │                        │   386  7                │
  1244.   │                     │                        │   486  4                │
  1245.   │                     │                        │ Pentm  4                │
  1246.   ├─────────────────────┴────────────────────────┴─────────────────────────┤
  1247.   │ 1100 000,w   mod,000,r/m   0, 2, or 4 byte displacement                │
  1248.   │ 1 byte immediate date                                                  │
  1249.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1250.   │ ROL reg,immed8      │ ROL EAX,5              │ 88/86  N/A              │
  1251.   │                     │                        │   286  5+n              │
  1252.   │                     │                        │   386  3                │
  1253.   │                     │                        │   486  2                │
  1254.   │                     │                        │ Pentm  1                │
  1255.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  1256.   │ ROL mem,immed       │ ROL WORD PTR [BX],2    │ 88/86  N/A              │
  1257.   │                     │                        │   286  8+n              │
  1258.   │                     │                        │   386  7                │
  1259.   │                     │                        │   486  4                │
  1260.   │                     │                        │ Pentm  3                │
  1261.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  1262.  
  1263. ───────────────────────────────────────────────────────────────────────────────
  1264. SBB              Subtract with Borrow                Flags: O D I T S Z A P C
  1265.                                                             *       * * * * * 
  1266.  
  1267. SYNTAX:
  1268.   SBB      destination,source
  1269.  
  1270. LOGIC:
  1271.   IF CF = 1 THEN
  1272.      destination  destination - source - 1
  1273.   ELSE
  1274.      destination  destination - source
  1275.   ENDIF
  1276.  
  1277.        This instruction subtracts the source operand and the value of the
  1278.   carry flag from the destination operand and stores the result in the
  1279.   destination operand.  This is usually used to perform "multi-element
  1280.   subtraction" in order to subtract quantities that are larger than the
  1281.   largest operand supported by the processor.
  1282.  
  1283.        In a multi-element subtraction, the quantities are subtracted using
  1284.   multiple subtraction operations that start with the least significant
  1285.   portion (byte, word or doubleword) of the quantities and proceed to the
  1286.   most significant portion.  The first subtraction is performed with a
  1287.   regular SUB instruction (or SBB if the carry flag is previously cleared)
  1288.   and the remaining subtractions use the SBB instruction. Note: the
  1289.   quantities to be subtracted can be either signed or unsigned.
  1290.  
  1291. EXAMPLE
  1292.        This example subtracts the 32 bit number in CX:BX from the 32 bit
  1293.   number in DX:AX and stores the result in DX:AX.
  1294.  
  1295.            SUB     AX,BX                         ; Subtract least significant word.
  1296.            SBB     DX,CX                         ; Subtract most significant word with borrow.
  1297.  
  1298.        This example performs a multi-element subtraction of two operands
  1299.   specified by pointers in SI and DI and whose length is specified in CX.
  1300.   This example relies on the fact that when SI is adjusted with an INC
  1301.   instruction, the carry flag is not affected.  This is probably the main
  1302.   reason that INC and DEC do not update the carry flag.
  1303.  
  1304.            CLC                                   ; Clear carry for first subtraction.
  1305.  
  1306. SUBTOP:    MOV     AL,[DI]                       ; Get next destination byte.
  1307.            SBB     AL,[SI]                       ; Subtract off next source byte.
  1308.            STOSB                                 ; Store result
  1309.            INC     SI                            ; Point to next source byte.
  1310.            LOOP    SUBTOP                        ; Loop back for next byte, if any.
  1311.  
  1312.        Another use for the SBB instruction is negate boolean values.  If
  1313.   boolean values are represented using the C system that 0 is true and
  1314.   non-zero is false, then the following code can be used to negate boolean
  1315.   values without using branches (jumps).
  1316.  
  1317.            CMP     FLAG,1                        ; Set carry if flag is false.
  1318.            SBB     AL,AL                         ; Set AL to value of carry.
  1319.            MOV     FLAG,AL                       ; Save inverted flag.
  1320.  
  1321.   This code works follows as follows.  The flag is compared to 1.  This will
  1322.   set the carry only if the flag was false (0).  Then a register is
  1323.   subtracted from itself with SBB.  Regardless of the previous contents of
  1324.   the register, this will yield 0 (false) if the carry is clear and -1 if
  1325.   the carry was set.  Thus it yields a boolean value opposite the one
  1326.   tested.  Note that in C (and many other languages) any non-zero value will
  1327.   be treated as true, but logical operations will always return true as -1.
  1328.   This code follows that practice.
  1329.  
  1330.   ┌────────────────────────────────────────────────────────────────────────┐
  1331.   │ 0001 10,d,w   mod,reg,r/m   0, 2, or 4 byte displacement               │
  1332.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1333.   │ SBB reg,reg         │ SBB DX,CX              │ 88/86  3                │
  1334.   │                     │                        │   286  2                │
  1335.   │                     │                        │   386  2                │
  1336.   │                     │                        │   486  1                │
  1337.   │                     │                        │ Pentm  1                │
  1338.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  1339.   │ SBB mem,reg         │ SBB NUMBER,CL          │ 88/86  16+EA            │
  1340.   │                     │                        │  WD88  24+EA            │
  1341.   │                     │                        │   286  7                │
  1342.   │                     │                        │   386  6                │
  1343.   │                     │                        │   486  3                │
  1344.   │                     │                        │ Pentm  3                │
  1345.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  1346.   │ SBB reg,mem         │ SBB CL,NUMBER          │ 88/86  9+EA             │
  1347.   │                     │                        │  WD88  13+EA            │
  1348.   │                     │                        │   286  7                │
  1349.   │                     │                        │   386  7                │
  1350.   │                     │                        │   486  2                │
  1351.   │                     │                        │ Pentm  2                │
  1352.   ├─────────────────────┴────────────────────────┴─────────────────────────┤
  1353.   │ 1000 00,s,w   mod,011,r/m   0, 2, or 4 byte displacement               │
  1354.   │ 1, 2, or 4 byte immediate data                                         │
  1355.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1356.   │ SBB reg,immed       │ SBB BX,1992            │ 88/86  4                │
  1357.   │                     │                        │   286  3                │
  1358.   │                     │                        │   386  2                │
  1359.   │                     │                        │   486  1                │
  1360.   │                     │                        │ Pentm  1                │
  1361.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  1362.   │ SBB mem,immed       │ SBB NUMBER,DX          │ 88/86  17+EA            │
  1363.   │                     │                        │  WD88  25+EA            │
  1364.   │                     │                        │   286  7                │
  1365.   │                     │                        │   386  7                │
  1366.   │                     │                        │   486  3                │
  1367.   │                     │                        │ Pentm  3                │
  1368.   ├─────────────────────┴────────────────────────┴─────────────────────────┤
  1369.   │ 0001 110,w   1, 2, or 4 byte immediate data                            │
  1370.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1371.   │ SBB accum,immed     │ SBB AX,1992            │ 88/86  4                │
  1372.   │                     │                        │   286  3                │
  1373.   │                     │                        │   386  2                │
  1374.   │                     │                        │   486  1                │
  1375.   │                     │                        │ Pentm  1                │
  1376.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  1377.  
  1378. ───────────────────────────────────────────────────────────────────────────────
  1379. TEST             Test                                Flags: O D I T S Z A P C
  1380.                                                             0       * * ? * 0
  1381.  
  1382. SYNTAX:
  1383.   TEST     destination,source
  1384.  
  1385. LOGIC:
  1386.   Flags set according to result of destination && source
  1387.  
  1388.        This instruction, performs a bitwise logical AND operation on its
  1389.   operands and sets the flags from the result.  Unlike the AND instruction,
  1390.   the result is discarded and neither operand is changed by this
  1391.   instruction.  This operation is frequently used to determine if a
  1392.   particular bit in a bitfield is set.  It can also be used to test if a
  1393.   group of bits in a bitfield value is clear.
  1394.  
  1395.        The TEST mem,reg instruction is not supported by the processor,
  1396.   however, most assemblers will assemble the instruction by transposing the
  1397.   operands and coding a TEST reg,mem instruction instead.  Since the logical
  1398.   AND operation is communitive and the result is not saved in either
  1399.   operand, this produces the same results.
  1400.  
  1401. EXAMPLE
  1402.        This example determines if bit 2 of CL is set.  CL is TESTed with a
  1403.   mask that has only bit 2 set.  If the result is non-zero, the bit was
  1404.   set, otherwise the bit was clear.
  1405.  
  1406.            TEST    CL,00000100Y                  ; AND value with mask.
  1407.            JNZ     BITSET                        ; If bit was set, branch around.
  1408.                                                  ; Continue here if not set.
  1409.  
  1410. EXAMPLE
  1411.        This example determines if the odd bits of a byte in memory are
  1412.   clear.  The byte is TESTed with a mask that has only the odd bits set.  If
  1413.   the result is zero, all the odd bits were clear, otherwise at least one
  1414.   odd bit was set.
  1415.  
  1416.            TEST    BYTE PTR [BX],10101010Y       ; AND value with mask.
  1417.            JZ      BITCLR                        ; If bits were clear, branch around.
  1418.                                                  ; Continue here if any bits were set.
  1419.  
  1420.   ┌────────────────────────────────────────────────────────────────────────┐
  1421.   │ 1000 010w   mod,reg,r/m   0, 2, or 4 byte displacement                 │
  1422.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1423.   │ TEST reg,reg        │ TEST DX,CX             │ 88/86  3                │
  1424.   │                     │                        │   286  2                │
  1425.   │                     │                        │   386  2                │
  1426.   │                     │                        │   486  1                │
  1427.   │                     │                        │ Pentm  1                │
  1428.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  1429.   │ TEST mem,reg        │ TEST NUMBER,CL         │ 88/86  9+EA             │
  1430.   │ Instruction not     │                        │  WD88  13+EA            │
  1431.   │ really available    │                        │   286  6                │
  1432.   │                     │                        │   386  5                │
  1433.   │                     │                        │   486  2                │
  1434.   │                     │                        │ Pentm  2                │
  1435.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  1436.   │ TEST reg,mem        │ TEST CL,NUMBER         │ 88/86  9+EA             │
  1437.   │                     │                        │  WD88  13+EA            │
  1438.   │                     │                        │   286  6                │
  1439.   │                     │                        │   386  5                │
  1440.   │                     │                        │   486  2                │
  1441.   │                     │                        │ Pentm  2                │
  1442.   ├─────────────────────┴────────────────────────┴─────────────────────────┤
  1443.   │ 1111 011,w   mod,000,r/m   0, 2, or 4 byte displacement                │
  1444.   │ 1, 2, or 4 byte immediate data                                         │
  1445.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1446.   │ TEST reg,immed      │ TEST BX,1992           │ 88/86  5                │
  1447.   │                     │                        │   286  3                │
  1448.   │                     │                        │   386  2                │
  1449.   │                     │                        │   486  1                │
  1450.   │                     │                        │ Pentm  1                │
  1451.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  1452.   │ TEST mem,immed      │ TEST NUMBER,DX         │ 88/86  11+EA            │
  1453.   │                     │                        │  WD88  11+EA            │
  1454.   │                     │                        │   286  6                │
  1455.   │                     │                        │   386  5                │
  1456.   │                     │                        │   486  2                │
  1457.   │                     │                        │ Pentm  2                │
  1458.   ├─────────────────────┴────────────────────────┴─────────────────────────┤
  1459.   │ 1010 100,w   1, 2, or 4 byte immediate data                            │
  1460.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1461.   │ TEST accum,immed    │ TEST AX,1992           │ 88/86  4                │
  1462.   │                     │                        │   286  3                │
  1463.   │                     │                        │   386  2                │
  1464.   │                     │                        │   486  1                │
  1465.   │                     │                        │ Pentm  1                │
  1466.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  1467.  
  1468. ───────────────────────────────────────────────────────────────────────────────
  1469. VERR             Verify Read                         Flags: O D I T S Z A P C
  1470.                                                                       *
  1471.  
  1472. SYNTAX:
  1473.   VERR     selector
  1474.  
  1475. LOGIC:
  1476.   IF selector is valid AND selector's segment is accessible at
  1477.      the current privilege level AND selector's segment is readable THEN
  1478.      ZF  1
  1479.   ELSE
  1480.      ZF  0
  1481.   ENDIF
  1482.  
  1483.        This instruction tests a selector to determine if it can be used
  1484.   without causing a general protection fault.  The instruction performs the
  1485.   same tests that the processor would if the selector were loaded into a
  1486.   data segment register (DS, ES, FS, or GS).  If any of the tests detect an
  1487.   error, the zero flag is cleared, otherwise the zero flag is set.  This
  1488.   instruction can be used to test a selector passed to a routine to make
  1489.   sure that the selector can be used without causing a general protection
  1490.   fault.  This allows the routine to detect the error before it occurs and
  1491.   to exit gracefully.
  1492.  
  1493.        The instruction performs the following tests.  It checks that the
  1494.   selector is for a descriptor that is within the bounds of the appropriate
  1495.   descriptor table (either the Global Descriptor Table (GDT) or the Local
  1496.   Descriptor Table (LDT)).  Then, it checks that the descriptor is for a
  1497.   readable code or data segment.  Finally, if the segment is not a
  1498.   conforming code segment, the instruction checks that the segment's
  1499.   Descriptor Privilege Level (DPL) is not more privileged (not numerically
  1500.   less) than either the Current Privilege Level (CPL) or the selector's
  1501.   Requester Privilege Level (RPL).
  1502.  
  1503.        This instruction is available only when the processor is operating in
  1504.   protected mode.
  1505.  
  1506.        There is a bug in this instruction on some versions of the 80386.  If
  1507.   there are no JMP or CALL instructions or instructions with memory operands
  1508.   in the instruction prefetch queue after the VERR, the processor will hang
  1509.   until an external interrupt occurs.  After the interrupt is handled
  1510.   execution will continue after the VERR instruction.  In most cases, the
  1511.   system timer interrupt will unhang the processor.  To avoid this problem,
  1512.   however, a jump can be encoded after each VERR instruction.  For example,
  1513.  
  1514.            VERR    AX                            ; Verify selector.
  1515.            JMP     $+2                           ; Jump to next instruction.
  1516.                                                  ; Execution continues here.
  1517.  
  1518.   ┌────────────────────────────────────────────────────────────────────────┐
  1519.   │ 0000 1111   0000 0000   mod,100,r/m   0, 2, or 4 byte displacement     │
  1520.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1521.   │ VERR reg16          │ VERR AX                │ 88/86  N/A              │
  1522.   │                     │                        │   286  14               │
  1523.   │                     │                        │   386  10               │
  1524.   │                     │                        │   486  11               │
  1525.   │                     │                        │ Pentm  7                │
  1526.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  1527.   │ VERR mem16          │ VERR WORD PTR [BX]     │ 88/86  N/A              │
  1528.   │                     │                        │   286  16               │
  1529.   │                     │                        │   386  11               │
  1530.   │                     │                        │   486  11               │
  1531.   │                     │                        │ Pentm  7                │
  1532.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  1533.  
  1534. ───────────────────────────────────────────────────────────────────────────────
  1535. WAIT             Wait                                Flags: O D I T S Z A P C
  1536.  
  1537.  
  1538. SYNTAX:
  1539.   WAIT
  1540.  
  1541. LOGIC:
  1542.   REPEAT
  1543.   UNTIL external TEST line is active
  1544.  
  1545.        This instruction can be used in a multiprocessor in environment to
  1546.   synchronize operation performed between processors.  The instruction can
  1547.   be used to suspend processing on a processor until another processor has
  1548.   completed a task.
  1549.  
  1550.   ┌────────────────────────────────────────────────────────────────────────┐
  1551.   │ 1001 1011                                                              │
  1552.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1553.   │ WAIT                │ WAIT                   │ 88/86  3                │
  1554.   │                     │                        │   286  3                │
  1555.   │                     │                        │   386  6                │
  1556.   │                     │                        │   486  1-3              │
  1557.   │                     │                        │ Pentm  1                │
  1558.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  1559.  
  1560. ───────────────────────────────────────────────────────────────────────────────
  1561. XCHG             Exchange Registers                  Flags: O D I T S Z A P C
  1562.  
  1563.  
  1564. SYNTAX:
  1565.   XCHG     destination,source
  1566.  
  1567. LOGIC:
  1568.   destination  source
  1569.  
  1570.        This instruction exchanges the value the stored in the destination
  1571.   operand with the value stored in the source operand.  Neither value is
  1572.   lost by this operation.  Each value ends up where the other one was
  1573.   stored.  One of the operands must be a general purpose register, the other
  1574.   operand may be a register or a memory location and must be of the same
  1575.   size.
  1576.  
  1577.        If one of the operands is a memory location, the instruction must be
  1578.   encoded so that the memory location is the source the operand.  However,
  1579.   most assemblers will allow a memory location to be specified in the
  1580.   destination, if the source is a register.  The assembler will simply
  1581.   encode the instruction with the operands reversed, which produces the same
  1582.   results.
  1583.  
  1584.        Since the exchange memory and register operation (XCHG reg,mem) is
  1585.   often used to simultaneously test and set flags in a multi-processor
  1586.   environment, the processor automatically asserts the lock signal (on 80286
  1587.   and later processors) for this instruction so, a lock prefix is
  1588.   unnecessary.
  1589.  
  1590. EXAMPLE
  1591.        This example uses an exchange instruction to simultaneously test and
  1592.   lock a flag in memory.  This is often performed in multi-processor
  1593.   environments, when flags in memory are used to control access to
  1594.   resources.  In the example, a memory location contains a flag that is -1
  1595.   when the resource is being used by a processor and is 0 when the resource
  1596.   is not being used.  The processor exchanges the flag with a register
  1597.   containing a -1.  This insures that the flag will be -1 after the
  1598.   exchange.  If the register is 0 after the exchange, then the resource was
  1599.   not being used, but is now being used by the current processor.  If the
  1600.   register is -1, then the resource is being used by a different processor.
  1601.   Since the XCHG instruction automatically asserts the LOCK signal when one
  1602.   of the operands is a memory location, this instruction cannot be performed
  1603.   simultaneously by two processors.  This prevents two processors from
  1604.   locking the flag simultaneously.
  1605.  
  1606.            MOV     AL,-1                         ; Load AL with locked value
  1607.  
  1608. LCKRESTOP: XCHG    AL,FLGBYT                     ; Get the flag.
  1609.            CMP     AL,-1                         ; Is resource in use?
  1610.            JZ      LCKRESTOP                     ; Yes, loop back to try again.
  1611.  
  1612.            *  *  *
  1613.  
  1614.            MOV     FLGBYT,0                      ; Release the resource.
  1615.  
  1616.   ┌────────────────────────────────────────────────────────────────────────┐
  1617.   │ 1000 011,w   mod,reg,r/m   0, 2, or 4 byte displacement                │
  1618.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1619.   │ XCHG reg,reg        │ XCHG AX,SI             │ 88/86  4                │
  1620.   │                     │                        │   286  3                │
  1621.   │                     │                        │   386  3                │
  1622.   │                     │                        │   486  3                │
  1623.   │                     │                        │ Pentm  3                │
  1624.   ├─────────────────────┼────────────────────────┼─────────────────────────┤
  1625.   │ XCHG reg,mem        │ XCHG AL,[DI]           │ 88/86  17+EA            │
  1626.   │                     │                        │  WD88  25+EA            │
  1627.   │                     │                        │   286  5                │
  1628.   │                     │                        │   386  5                │
  1629.   │                     │                        │   486  5                │
  1630.   │                     │                        │ Pentm  3                │
  1631.   ├─────────────────────┴────────────────────────┴─────────────────────────┤
  1632.   │ 1001 0,reg                                                             │
  1633.   ├─────────────────────┬────────────────────────┬─────────────────────────┤
  1634.   │ XCHG accum,reg16    │ XCHG AX,BX             │ 88/86  3                │
  1635.   │ XCHG accum,reg32    │                        │   286  3                │
  1636.   │                     │                        │   386  3                │
  1637.   │                     │                        │   486  3                │
  1638.   │                     │                        │ Pentm  2                │
  1639.   └─────────────────────┴────────────────────────┴─────────────────────────┘
  1640.  
  1641.